<!-- 功能尚不完善，未完善后端功能 -->
<template>
  <div class="user">
    <el-tree
      :data="menus"
      :props="defaultProps"
      show-checkbox
      node-key="name"
      ref="tree"
    ></el-tree>
    <el-button type="primary" @click="getPermission">获取权限</el-button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      menus: [],
      defaultProps: {
        label: 'name',
        children: 'children'
      }
    }
  },
  mounted () {
    this.menus = [...this.$router.options.routes]
  },
  methods: {
    getPermission () {
      let key = this.$refs.tree.getCheckedNodes()
      console.log(key)
    }
  }
}
</script>

<style lang="less">
.user {
  .el-tree {
    margin-top: 20px;
  }
}
</style>